package personal.wang.juc;

import java.util.concurrent.CompletableFuture;

public class CompletableFutureTest2 {
    public static void main(String[] args) throws InterruptedException {
        CompletableFuture<Integer> integerCompletableFuture = CompletableFuture.supplyAsync(() -> {
            int i = 1 / 0;
            return 1;
        }).applyToEither(CompletableFuture.supplyAsync(() -> {
                    return 2;
                }), r -> {
                    return 3;
                }
        ).exceptionally(throwable -> {
            System.out.println(throwable);
            return 4 ;
        });
//                .whenComplete((r, t) -> {
//            System.out.println(t);
//        });
        System.out.println(integerCompletableFuture.join());
        Thread.sleep(1000L);
    }
}
